<script>ui.block();</script>
<?php
   $db = new Database();
   $auth = Auth::getAuth('current_user');
   $userCompany = new userQueries();
   $company = $userCompany->getCompany($auth['company_id']);
   $form_id = $_GET['formID'];
   $form = $db->query("SELECT * FROM tb_workspace WS 
                            WHERE WS.id={$db->escape($form_id)}","row");
?>
<div class="form-workspace-mobility-json display"></div>
<div class="login-expire-security-id"><?php echo $auth["id"];?></div>
<div class="fl-create-forms-wrapper">
	<?php  include 'layout/workspace_header.php' ?>
	<div class="contentBar_workspace" style="margin-top:28px;">
	    <div class="fl-workspace-wrapper">
			<!-- <div class="fl-option-toolbar">
				<div class="fl-toolbar-left-wrapper">
					<i class="fa fa-list-alt"></i> <span>Form Builder</span>
				</div>
				<div class="fl-toolbar-right-wrapper">
					<ul class="fl-breadcrums">
						<li><a href="/home"><div class="home icon"></div> <i class="fa fa-caret-right"></i></a></li> 
						<li><a href="/user_view/organizational_chart">Organizational Chart <i class="fa fa-caret-right"></i></a></li> 
						<li><a href="/user_view/formbuilder">Form Builder <i class="fa fa-caret-right"></i></a></li> 
						<li><a href="/user_view/workflow">Workflow</a></li>
					</ul>
				</div>
			</div> -->
			<div class="fl-option-toolbar">
			 <div class="formbuilder_page_btn btn_content">
               <?php
                  if($form_id!=0){
                     $form = $db->query("SELECT * FROM tb_workspace 
                               WHERE id={$db->escape($form_id)}","row");
                     echo $form['button_content'];
                  }
               ?>
            </div>
            <?php
               if($form_id==0){
                  ?>
                  <div class="ws_btn_label  " style="padding-left: 10px;color: gray; font-size: 10px;">
                     Add Your Button Here.
                  </div>
                  <?php
               }
            ?>
        	</div>
			<div class="fl-workspace">
				 <div style="display:table;">
	         <div style="display:table-row">
	            <div style="display:table-cell"></div>
	            <div class="topPointerRuler-container" style="position:relative; display:table-cell;width: auto;height: 100%;border: 1px solid #ddd;border-bottom: none;">
	                  <div class="topPointerRuler-tip" style="width: 10px;background-color: #000;height: 10px;cursor: pointer;"></div>
	            </div>
	         </div>
	         <div style="display:table-row">
	            <div  class="leftPointerRuler-container" style="position:relative;display:table-cell;white-space:nowrap;vertical-align:top;width: 10px;height: 600px;border: 1px solid #ddd;">
	                  <div class="leftPointerRuler-tip" style="width: 10px;background-color: #000;height: 10px;cursor: pointer;"></div>
	            </div>
	            <div style="display:table-cell">
	              <div class="workspace formbuilder_ws" style="position:relative">
	                  <!-- Objects -->
			  <?php
			    if($form_id!=0){
			       echo $form['form_content'];
			    }else{
			       echo $form['form_content'];
			    }
	                  ?>
	               </div>
	            </div>
	         </div>
	      </div><!-- /end of display table -->
		<div class="display">
		    <input type="text" name="FormId" id="FormId" value="<?php echo $form_id; ?>" />
		</div>
			</div><!-- /end of fl-workspace -->
			<?php include 'layout/form_controls.php' ?>
			<!-- <div class="fl-form-properties-wrapper">
				<div class="fl-widget-head">
					<span class="widget-title"><i class="fa fa-cogs"></i> properties</span>
					<div class="fl-form-properties-toggle">
						<i class="fa fa-chevron-right"></i>
					</div>
				</div>
				<div class="fl-props-container">
					<div class="fl-form-setting-wrapper">
						<div class="fl-widget-head">
						    <span class="widget-title">Form Settings</span>
						    <span class="fl-min-max-properties" fl-show-opt="true"><i class="fa fa-plus"></i></span>
						</div>
						<div class="fl-form-setting-content fl-for-scroll">
							<label>Custom Form Size</label>
							<div class="fl-option-form-wrapper">
								<input type="text" name="" class="form-text form_set_size form_size_width" style="width: 49%;" placeholder="Width" value="1030">
								<input type="text" name="" class="form-text form_set_size form_size_height" style="width: 49%;" placeholder="Height" value="600">
								<div class="clearfix"></div>
							</div>
							<div class="fl-option-form-wrapper">
								<label>Form Size</label>
								<select class="form-select form_size">
								    <option value="8.5x11">Letter(8.5in x 11in)</option> 
								    <option value="8.5x14">Legal(8.5in x 14in)</option> 
								    <option value="7.25x10.5">Executive(7.25in x 10.5in)</option> 
								    <option value="8.27x11.69">A4(8.27in x 11.69in)</option> 
								    <option value="33.11x46.61">A0(33.11in x 46.61in)</option> 
								    <option value="23.39x33.11">A1(23.39in x 33.11in)</option> 
								    <option value="16.53x23.39">A2(16.53in x 23.39in)</option> 
								    <option value="11.69x16.53">A3(11.69in x 16.53in)</option> 
								    <option value="8.27x11.69">A4(8.27in x 11.69in)</option> 
								</select>	
							</div>
							<div class="fl-option-form-wrapper">
								<label>Show Ruler</label><Br/>
								<label>Yes: <input type="radio" class="f-show-ruler" value="yes" name="show-form-ruler-select"/></label>
								<label>No: <input type="radio" class="f-show-ruler" checked="checked" value="no" name="show-form-ruler-select"/></label>
							</div>
						</div>
					</div>
					<div class="fl-form-actions-wrapper">
						<div class="fl-widget-head">
							<span class="widget-title">Form Actions</span>
							<span class="fl-min-max-properties" fl-show-opt="true"><i class="fa fa-plus"></i></span>
						</div>
						<div class="fl-form-actions-content fl-for-scroll">
							<button class="btn-basicBtn padding_5 cursor save_workspace fl-command-btn tip" data-original-title="Save Form" data-workspace="Formbuilder" data-form-type="formbuilder"><i class="fa fa-save"></i> Save</button>
							<button class="btn-basicBtn padding_5 cursor clear_all_formbuilder_workspace fl-command-btn tip" data-original-title="Clear Workspace"><i class="fa fa-times"></i> Clear All</button>
							<button class="btn-basicBtn padding_5 cursor preview_form fl-command-btn tip" data-original-title="Preview Form" data-form-type="formbuilder"><i class="fa fa-search"></i> Preview</button>
							<button class="btn-basicBtn padding_5 cursor mobility-setup fl-command-btn tip" data-original-title="Mobility" data-form-type=""><i class="fa fa-mobile"></i> Mobility</button>
							<button class="btn-basicBtn padding_5 cursor form-authors tip fl-command-btn" data-original-title="Set Authors" data-form-type=""><i class="fa fa-pencil-square"></i> Authors</button>
							<button class="btn-basicBtn padding_5 cursor form-readers tip fl-command-btn" data-original-title="Set Viewers" data-form-type=""><i class="fa fa-folder-open"></i> Viewers</button>
							<button class="btn-basicBtn padding_5 cursor form-admin tip fl-command-btn" data-original-title="Form Admin" data-form-type=""><i class="fa fa-user"></i> Form Admin</button>
							<button class="btn-basicBtn padding_5 cursor form-header-info tip fl-command-btn" data-original-title="Set Header Info." data-form-type=""><i class="fa fa-info-circle"></i> Header Info.</button>
							<button class="btn-basicBtn padding_5 cursor form-customized tip fl-command-btn" data-original-title="Set Customized Author" data-form-type=""><i class="fa fa-print"></i> Customize Print</button>	
							<?php
                            $getWorkflow = $db->query("SELECT * FROM tbworkflow WHERE form_id = {$db->escape($_GET['formID'])} AND is_active=1","array");
                            if(count($getWorkflow)==1){
                                $wfPath = "workflow?view_type=edit&form_id=". $_GET['formID'] ."&id=". $getWorkflow[0]['id'] ."";
                                ?>
                                    <a href="<?php echo $wfPath; ?>" class="tip cursor" data-original-title="Active Workflow" data-placement="top" id="" data-form-id="1" style=""><button class="btn-basicBtn padding_5 cursor fl-command-btn" style=""><i class="fa fa-retweet"></i> Workflow</button></a>
                                <?php
                            }
                            ?>
						</div>
					</div>
					<div class="fl-form-controls-wrapper fl-for-scroll">
						<div class="fl-widget-head">
							<span class="widget-title">Form Controls</span>
							<span class="fl-min-max-properties" fl-show-opt="true"><i class="fa fa-plus"></i></span>
						</div>
						<div class="fl-form-controls-content" style="overflow:hidden;position: relative;">
							 <button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Label"  data-object-type="labelOnly" data-drop="workspace"><i class="fa fa-font"></i> Label Only</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Tab" data-object-type="tabPanel" data-drop="workspace" ><i class="fa fa-share-square"></i> Tab Panel</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="TextBox"  data-object-type="textbox" data-drop="workspace"><i class="fa fa-square-o"></i> TextBox</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="TextArea" data-object-type="textarea" data-drop="workspace"><i class="fa fa-square-o"></i> Text Area</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Checkbox" data-object-type="checkbox" data-drop="workspace"><i class="fa fa-check-square-o"></i> CheckBox</button>
									       <button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Radio Button" data-object-type="radioButton" data-drop="workspace"><i class="fa fa-dot-circle-o"></i> Radio Button</button>	
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Dropdown" data-object-type="dropdown" data-drop="workspace"><i class="fa fa-caret-square-o-down"></i> Dropdown</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Select Many" data-object-type="selectMany" data-drop="workspace"><i class="fa fa-list-ul"></i> Select Many</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Date Time" data-object-type="dateTime" data-drop="workspace"><i class="fa fa-clock-o"></i> Date Time</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Date Picker" data-object-type="datepicker" data-drop="workspace"><i class="fa fa-calendar"></i> Date Picker</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Table" data-object-type="table" data-drop="workspace"><i class="fa fa-table"></i> Table</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Line" data-object-type="line" data-drop="workspace"><i class="fa fa-ellipsis-h"></i> Add Line</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Button" data-object-type="button" data-drop="formbuilder_page_btn"><i class="fa fa-square"></i> Button</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Names" data-object-type="listNames" data-drop="workspace"><i class="fa fa-th-list"></i> Names</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Computed" data-object-type="computed" data-drop="workspace"><i class="fa fa-file-text"></i> Computed</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Image" data-object-type="image" data-drop="workspace">
							    <form id="getformImage" method="post" enctype="multipart/form-data" action="/ajax/formUpload">
								<input type="file" data-action-id="2" value="upload" name="image" id="formImage" size="24" data-action-type="postImageForm" style="opacity: 0;position: absolute;" class=""><i class="fa fa-picture-o"></i> Image
							    </form>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Embed View" data-object-type="embedView" data-drop="workspace"><i class="fa fa-eye"></i> Embed View</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Pick List" data-object-type="pickList" data-drop="workspace"><i class="fa fa-calendar"></i> Pick List</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Request Image" data-object-type="requestImage" data-drop="workspace"><i class="fa fa-picture-o"></i> Request Image</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Bar Code Scanner" data-object-type="barCodeScanner" data-drop="workspace"><i class="fa fa-qrcode"></i> Bar Code</button>
							<button class="btn-basicBtn padding_5 cursor getObjects tip fl-command-btn" data-original-title="Time" data-object-type="time" data-drop="workspace"><i class="fa fa-clock-o"></i> Time</button>                              
						</div>
					</div>
				</div>
			</div> --><!-- /end of fl-form-properties -->
			<div class="clearfix"></div>
		</div>
	</div>	
</div>

<?php
$search = new Search();

//get departments
$getAllDepartment = $search->getAllDepartment();
echo "<div class='departments display'>" . json_encode($getAllDepartment) . "</div>";

//get positions
$getPosition = $search->getAllPosition();
echo "<div class='positions display'>" . json_encode($getPosition) . "</div>";

//get users
$getUsers = $search->getAllUsers("");
echo "<div class='users display'>" . json_encode($getUsers) . "</div>";
//get users
$getUsers = $search->getAllUsers("AND user_level_id = 2 AND id != '". $auth['id'] ."'");
echo "<div class='users-admin display'>" . json_encode($getUsers) . "</div>";
?>